package com.geyb.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class HttpUtil {
	public static String sendGet(String url){
		StringBuffer rBuff = new StringBuffer();
		HttpURLConnection conn = null;
		try {
			conn = (HttpURLConnection) new URL(url).openConnection();
			conn.setRequestMethod("GET");
			conn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Firefox/24.0");
			conn.setRequestProperty("Content", "text/html");
			conn.setRequestProperty("Vary", "Accept-Encoding");
			conn.setRequestProperty("Cache-Control", "max-age=864000");
			conn.setRequestProperty("Content-Encoding", "gzip");
			conn.setRequestProperty("contentType", "UTF-8"); 
			
			BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
			String line = "";
			while((line = br.readLine()) != null){
				rBuff.append(line).append("\n");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return rBuff.toString();
	}
	
	public static String sendPost(String url , byte[] body){
		return "";
	}
	
	public static void main(String[] args) {
		System.out.println(sendGet("http://www.pceggs.com/play/PG28Trend.aspx"));
	}
}
